package com.dandan.tzx.router;

import android.content.Context;
import android.util.Log;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Interceptor;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.template.IInterceptor;

/**
 * Created by tanzhenxing
 * Date: 2018/1/6 上午11:55
 * Description:
 */

@Interceptor(priority = 8)
public class InterceptorImpl implements IInterceptor {
    String TAG = "InterceptorImpl";
    @Override
    public void process(Postcard postcard, InterceptorCallback callback) {
        Log.d(TAG, "process() called with: postcard = [" + postcard.getPath() + "]");
        if (postcard.getGroup().equals("activity")) {
            callback.onContinue(postcard);
        } else if (postcard.getGroup().equals("activity1")) {
            callback.onInterrupt(new RuntimeException("activity1"));
        } else {
            callback.onContinue(postcard);
        }
        if (postcard.getExtra() == 10) {
            Log.d(TAG, "process() called with: postcard = [" + postcard.getGroup() + "]");
        }
    }

    @Override
    public void init(Context context) {
        Log.d(TAG, "init() called with: context = [" + context + "]");
    }
}
